import 'package:flutter_deer/generated/json/base/json_convert_content.dart';
import 'package:flutter_deer/database/beans/discount/post_discount_count_entity.dart';
import 'package:flutter_deer/database/beans/get_user_info_entity.dart';

import 'package:flutter_deer/database/beans/pay/create_order_entity.dart';


PostDiscountCountEntity $PostDiscountCountEntityFromJson(Map<String, dynamic> json) {
  final PostDiscountCountEntity postDiscountCountEntity = PostDiscountCountEntity();
  final bool? canUseStoreCoupon = jsonConvert.convert<bool>(json['canUseStoreCoupon']);
  if (canUseStoreCoupon != null) {
    postDiscountCountEntity.canUseStoreCoupon = canUseStoreCoupon;
  }
  final String? energyCategoryId = jsonConvert.convert<String>(json['energyCategoryId']);
  if (energyCategoryId != null) {
    postDiscountCountEntity.energyCategoryId = energyCategoryId;
  }
  final String? energyGoodsId = jsonConvert.convert<String>(json['energyGoodsId']);
  if (energyGoodsId != null) {
    postDiscountCountEntity.energyGoodsId = energyGoodsId;
  }
  final String? goodsAmount = jsonConvert.convert<String>(json['goodsAmount']);
  if (goodsAmount != null) {
    postDiscountCountEntity.goodsAmount = goodsAmount;
  }
  final String? goodsPrice = jsonConvert.convert<String>(json['goodsPrice']);
  if (goodsPrice != null) {
    postDiscountCountEntity.goodsPrice = goodsPrice;
  }
  final String? mchCode = jsonConvert.convert<String>(json['mchCode']);
  if (mchCode != null) {
    postDiscountCountEntity.mchCode = mchCode;
  }
  final String? mchMemberId = jsonConvert.convert<String>(json['mchMemberId']);
  if (mchMemberId != null) {
    postDiscountCountEntity.mchMemberId = mchMemberId;
  }
  final String? memberAccountId = jsonConvert.convert<String>(json['memberAccountId']);
  if (memberAccountId != null) {
    postDiscountCountEntity.memberAccountId = memberAccountId;
  }
  final String? payMethod = jsonConvert.convert<String>(json['payMethod']);
  if (payMethod != null) {
    postDiscountCountEntity.payMethod = payMethod;
  }
  final String? payType = jsonConvert.convert<String>(json['payType']);
  if (payType != null) {
    postDiscountCountEntity.payType = payType;
  }
  final String? quantity = jsonConvert.convert<String>(json['quantity']);
  if (quantity != null) {
    postDiscountCountEntity.quantity = quantity;
  }
  final List<StoreGoodsInfos>? storeGoodsInfos = (json['storeGoodsInfos'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<StoreGoodsInfos>(e) as StoreGoodsInfos).toList();
  if (storeGoodsInfos != null) {
    postDiscountCountEntity.storeGoodsInfos = storeGoodsInfos;
  }
  return postDiscountCountEntity;
}

Map<String, dynamic> $PostDiscountCountEntityToJson(PostDiscountCountEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['canUseStoreCoupon'] = entity.canUseStoreCoupon;
  data['energyCategoryId'] = entity.energyCategoryId;
  data['energyGoodsId'] = entity.energyGoodsId;
  data['goodsAmount'] = entity.goodsAmount;
  data['goodsPrice'] = entity.goodsPrice;
  data['mchCode'] = entity.mchCode;
  data['mchMemberId'] = entity.mchMemberId;
  data['memberAccountId'] = entity.memberAccountId;
  data['payMethod'] = entity.payMethod;
  data['payType'] = entity.payType;
  data['quantity'] = entity.quantity;
  data['storeGoodsInfos'] = entity.storeGoodsInfos?.map((v) => v.toJson()).toList();
  return data;
}

extension PostDiscountCountEntityExtension on PostDiscountCountEntity {
  PostDiscountCountEntity copyWith({
    bool? canUseStoreCoupon,
    String? energyCategoryId,
    String? energyGoodsId,
    String? goodsAmount,
    String? goodsPrice,
    String? mchCode,
    String? mchMemberId,
    String? memberAccountId,
    String? payMethod,
    String? payType,
    String? quantity,
    List<StoreGoodsInfos>? storeGoodsInfos,
  }) {
    return PostDiscountCountEntity()
      ..canUseStoreCoupon = canUseStoreCoupon ?? this.canUseStoreCoupon
      ..energyCategoryId = energyCategoryId ?? this.energyCategoryId
      ..energyGoodsId = energyGoodsId ?? this.energyGoodsId
      ..goodsAmount = goodsAmount ?? this.goodsAmount
      ..goodsPrice = goodsPrice ?? this.goodsPrice
      ..mchCode = mchCode ?? this.mchCode
      ..mchMemberId = mchMemberId ?? this.mchMemberId
      ..memberAccountId = memberAccountId ?? this.memberAccountId
      ..payMethod = payMethod ?? this.payMethod
      ..payType = payType ?? this.payType
      ..quantity = quantity ?? this.quantity
      ..storeGoodsInfos = storeGoodsInfos ?? this.storeGoodsInfos;
  }
}